home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / alib / csup / intuition_support / hookface.asm < prev    next >
Encoding:
Assembly Source File  |  1995-12-24  |  1.9 KB  |  74 lines

  1. *  $Id: hookface.asm,v 30.0 1994/06/10 18:10:22 dice Exp $
  2.  
  3.     INCLUDE 'exec/types.i'
  4.     INCLUDE 'utility/hooks.i'
  5.  
  6.     xdef    _CallHook
  7.     xdef    _CallHookA
  8.     xdef    _HookEntry
  9.  
  10. ****************************************************************************
  11. * new hook standard
  12. * use struct Hook (with minnode at the top)
  13. *
  14. * *** register calling convention: ***
  15. *    A0 - pointer to hook itself
  16. *    A1 - pointer to parameter packed ("message")
  17. *    A2 - Hook specific address data ("object," e.g, gadget )
  18. *
  19. * ***  C conventions: ***
  20. * Note that parameters are in unusual register order: a0, a2, a1.
  21. * This is to provide a performance boost for assembly language
  22. * programming (the object in a2 is most frequently untouched).
  23. * It is also no problem in "register direct" C function parameters.
  24. *
  25. * calling through a hook
  26. *    CallHook( hook, object, msgid, p1, p2, ... );
  27. *    CallHookA( hook, object, msgpkt );
  28. *
  29. * using a C function:    CFunction( hook, object, message );
  30. *    hook.h_Entry = HookEntry;
  31. *    hook.h_SubEntry = CFunction;
  32. *
  33. ****************************************************************************
  34.  
  35. * C calling hook interface for prepared message packet
  36. _CallHookA:
  37.     movem.l    a2/a6,-(sp)    ; protect
  38.     move.l    12(sp),a0    ; hook
  39.     move.l    16(sp),a2    ; object
  40.     move.l    20(sp),a1    ; message
  41.     ; ------ now have registers ready, invoke function
  42.     pea.l    hreturn(pc)
  43.     move.l    h_Entry(a0),-(sp)    ; old rts-jump trick
  44.     rts
  45. hreturn:
  46.     movem.l    (sp)+,a2/a6
  47.     rts
  48.  
  49. * C calling hook interface for "varargs message packet"
  50. _CallHook:
  51.     movem.l    a2/a6,-(sp)    ; protect
  52.     move.l    12(sp),a0    ; hook
  53.     move.l    16(sp),a2    ; object
  54.     lea.l    20(sp),a1    ; message
  55.     ; ------ now have registers ready, invoke function
  56.     pea.l    hpreturn(pc)
  57.     move.l    h_Entry(a0),-(sp)    ; old rts-jump trick
  58.     rts
  59. hpreturn:
  60.     movem.l    (sp)+,a2/a6
  61.     rts
  62.  
  63. * entry interface for C code (large-code, stack parameters)
  64. _HookEntry:
  65.     move.l    a1,-(sp)
  66.     move.l    a2,-(sp)
  67.     move.l    a0,-(sp)
  68.     move.l    h_SubEntry(a0),a0    ; C entry point
  69.     jsr    (a0)
  70.     lea    12(sp),sp
  71.     rts
  72.  
  73.     end
  74.